<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<table class="tab" border="1" style="table-layout:fixed;">
	<tr>
		<td align="center">用户ID1</td>
		<td align="center">用户姓名</td>
		<td align="center">用户电话</td>
		<td align="center">用户余额</td>
		<td align="center">订单金额</td>
	</tr>
	<tr>
		<td align="center"><s:property value="#request.balancePay.userId" /></td>
		<td align="center"><s:property value="#request.balancePay.username" /></td>
		<td align="center"><s:property value="#request.balancePay.mobile" /></td>
		<td align="center"><s:property value="#request.balancePay.user_balance" /></td>
		<td align="center"><s:property value="#request.balancePay.orderPrice" /></td>
	</tr>
</table>
<br>
<table class="tab" border="1" style="table-layout:fixed;">
	<tr>
		<td align="center">快递员ID</td>
		<td align="center">快递员姓名</td>
		<td align="center">快递员电话</td>
		<td align="center">快递员余额</td>
		<td align="center">订单金额</td>
	</tr>
	<tr>
		<td align="center"><s:property value="#request.balancePay.courierId" /></td>
		<td align="center"><s:property value="#request.balancePay.realname" /></td>
		<td align="center"><s:property value="#request.balancePay.c_mobile" /></td>
		<td align="center"><s:property value="#request.balancePay.cmoney" /></td>
		<td align="center"><s:property value="#request.balancePay.orderPrice" /></td>
	</tr>
</table>
<br/>
<br/>
<c:if test="${balancePay.userPay==0}">
	<div class="head">
		扣除用户&nbsp;<span class="show">${balancePay.username}</span>&nbsp;的余额&nbsp;<input id="in" name="orderPrice" onblur="checkMoney();" style="width: 60px;height: 30px;font-size: 20px;color: red;font-weight: 500" type="text" value="${balancePay.orderPrice}"/><span class="show"></span>&nbsp;元，支付给快递员&nbsp;<span class="show">${balancePay.realname}</span>
	</div>
	<br/>
	<br/>
	<div id="sureSub">
		<input class="sub" type="button" onclick="doBalancePay();" value="确认支付"/>
	</div>
</c:if>
<c:if test="${balancePay.userPay==1}">
	<div class="head">
		<span class="t2">用户已支付，不能重复支付！！！</span>
	</div>
</c:if>
<br/>
<br/>

<div id="afterChange">
	
</div>





<script type="text/javascript">
	function doBalancePay(){
		var user_balance = ${balancePay.user_balance};
		var userPay = ${balancePay.userPay};
		var orderPrice1 = $("#in").val();
		if(userPay == 1){
			alert("用户已经支付，不能重复支付！！！");
			return;
		}
		if(orderPrice1 > user_balance){
			alert("用户余额不足，不能支付！！！");
			return;
		}
		$.ajax({
			type:'post',
			data:{orderPrice:orderPrice1},
			url:'<%=basePath%>goPayAction',
			success:function(data){
				var newBalancePay = JSON.parse(data);
				var strHtml = '<div class="head2">'+
				'<span class="show">支付成功，用户和快递员的信息如下：</span>'+
				'</div>'+ 
				'<br/>'+
				'<table class="tab" border="1" style="table-layout:fixed;">'+
					'<tr>'+
						'<td align="center">用户ID</td>'+
						'<td align="center">用户姓名</td>'+
						'<td align="center">用户电话</td>'+
						'<td align="center">用户余额</td>'+
						'<td align="center">实际扣款</td>'+
					'</tr>'+
					'<tr>'+
						'<td align="center">'+newBalancePay.userId+'</td>'+
 						'<td align="center">'+newBalancePay.username+'</td>'+
						'<td align="center">'+newBalancePay.mobile+'</td>'+
						'<td align="center">'+newBalancePay.user_balance+'</td>'+ 
						'<td align="center">'+newBalancePay.sureMoney+'</td>'+ 
					'</tr>'+
				'</table>'+
				'<br/>'+
				'<table class="tab" border="1" style="table-layout:fixed;">'+
					'<tr>'+
						'<td align="center">快递员ID</td>'+
						'<td align="center">快递员姓名</td>'+
						'<td align="center">快递员电话</td>'+
						'<td align="center">快递员余额</td>'+
						'<td align="center">实际加钱</td>'+
					'</tr>'+
					'<tr>'+
 						'<td align="center">'+newBalancePay.courierId+'</td>'+
						'<td align="center">'+newBalancePay.realname+'</td>'+
						'<td align="center">'+newBalancePay.c_mobile+'</td>'+
						'<td align="center">'+newBalancePay.cmoney+'</td>'+ 
						'<td align="center">'+newBalancePay.sureMoney+'</td>'+ 
					'</tr>'+
				'</table>';
				$("#afterChange").html(strHtml);
				$("#sureSub").html("");
			}
		});
	}
	
	
	function checkMoney(){
		var a = $("#in").val();
		if(a > 300){
			alert("扣款金额不能大于300");
			$("#in").val("${balancePay.orderPrice}");
		}
	}
	
</script>

<style type="text/css">
	.head{font-size: 20px;margin-left: 300px;}
	.show{font-size: 20px;color:red;font-weight: 700;}
	.tab{margin-left: 150px;width: 900px;height: 75px;margin-top: 20px;}
	.sub{margin-left: 600px;background-color: #60ea60;width: 80px;height: 37px;}
	.head2{margin-left: 150px;}
	.t2{color:red;font-size: 20px;}
</style>
